#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
char* convertToBase7(int num)
{
    
    if(num == 0)
        return "0";
    char *s = (char*)malloc(sizeof(char)*32);
    bool c = num < 0;
    int pos = 0;
    num = abs(num);
    while(num != 0)
    {
        s[pos++] = num % 7 + '0';
        num /= 7;
    }
    if(c)
        s[pos++] = '-';
    for(int i = 0;i < pos/2;i++)
    {
        char p = s[i];
        s[i] = s[pos - i - 1];
        s[pos - i - 1] = p;
    }
    
    s[pos] = '\0';
    return s;

}
int main()
{
    int num = 200;
    char * s = convertToBase7(num);
    printf("%s\n",s);
    free(s);
    return 0;
}